package data;

import java.util.Date;

import com.EntityName;
import com.google.appengine.api.datastore.Entity;

public class ValidityConsole extends AbstractData {
	private long id = -1;
	private long hotelId;
	private Date startdate;
	private Date enddate;
	private long consoleId;
	private boolean status;
	private boolean avaliable;

	@Override
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	public Date getStartdate() {
		return startdate;
	}

	public void setStartdate(Date startdate) {
		this.startdate = startdate;
	}

	public Date getEnddate() {
		return enddate;
	}

	public void setEnddate(Date enddate) {
		this.enddate = enddate;
	}
	
	public long getHotelId() {
		return hotelId;
	}
	public void setHotelId(long hotelId) {
		this.hotelId = hotelId;
	}
	
	public long getConsoleId() {
		return consoleId;
	}
	public void setConsoleId(long consoleId) {
		this.consoleId = consoleId;
	}
	
	public boolean isStatus() {
		return status;
	}
	public void setStatus(boolean status) {
		this.status = status;
	}
	public boolean isAvaliable() {
		return avaliable;
	}
	public void setAvaliable(boolean avaliable) {
		this.avaliable = avaliable;
	}
	
	@Override
	public Entity getEntity() {
		Entity item;
		if(this.key == null)
			item = new Entity(EntityName.ValidityConsole);
		else
			item = new Entity(this.key);
		
		item.setProperty("hotelId", this.hotelId);
		item.setProperty("startdate", this.startdate);
		item.setProperty("enddate", this.enddate);
		item.setProperty("consoleId", this.consoleId);
		item.setProperty("status", this.status);
		item.setProperty("avaliable", this.avaliable);
		return item;
	}

	@Override
	public void setEntity(Entity entity) {
		this.id = entity.getKey().getId();
		this.hotelId = (Long) entity.getProperty("hotelId");
		this.startdate = (Date) entity.getProperty("startdate");
		this.enddate = (Date) entity.getProperty("enddate");
		this.consoleId = (Long) entity.getProperty("consoleId");
		this.status = (Boolean) entity.getProperty("status");
		this.avaliable = (Boolean) entity.getProperty("avaliable");
		this.key = entity.getKey();
	}

	public void LoadData()
	{
		if(this.id > -1)
		{
			Entity entity = LoadData(EntityName.ValidityConsole,this.id);
			setEntity(entity);
		}
	}
}
